Fix IOBuffer data race in stdio_loop / take!#120
Merged
giordano merged 1 commit intoJuliaTesting:mainfrom Mar 26, 2026
Merged
Conversation
Two background tasks (stdout + stderr) wrote to the same IOBuffer concurrently, and the main test loop called take! without any synchronisation. Julia's IOBuffer is not thread-safe, so this caused torn reads of io.size vs io.data under higher I/O load, manifesting as: DimensionMismatch: Attempted to wrap a MemoryRef of length N with an Array of size dims=(M,) Fix: add a ReentrantLock to PTRWorker; both stdio_loop write tasks and the take! call in runtests hold the lock. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Example stack trace: |
Collaborator
|
This is now live in v2.5.1 |
Contributor
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I got some ParallelTestRunner 2.5.0 failures that seem to be related to concurrent accesses to an IOBuffer; I will post a full stack trace in comments. This PR is AI-assisted, but it seems reasonable to the best of my knowledge and I have manually tested and verified that it does indeed fix the issue.
Detailed description:
Two background tasks (stdout + stderr) wrote to the same IOBuffer concurrently, and the main test loop called take! without any synchronisation. Julia's IOBuffer is not thread-safe, so this caused torn reads of io.size vs io.data under higher I/O load, manifesting as:
The proposed fix involves adding a
ReentrantLocktoPTRWorker; both stdio_loopwritetasks and thetake!call inruntestshold the lock.